Hardware acceleration of web applications

ABSTRACT

In a first embodiment of the present invention, a method for enabling hardware acceleration of web applications is provided, comprising: parsing a web page using a scripting engine, wherein the web page necessitates running a web application; accessing one or more Application Program Interfaces (APIs) that provide parallelization, and distribute tasks of the web application among multiple cores of a multi-core central processing unit (CPU) or graphical processing unit (GPU), wherein the accessing uses a compute context class that, when instantiated, creates a compute context object that acts as a bridge between the scripting engine and the one or more APIs; and creating one or more kernels to operate on the multiple cores.

CROSS REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. Non-Provisional patent application Ser. No. 13/492,761, filed Jun. 8, 2012 which claims the priority benefit of U.S. Provisional Patent Application No. 61/590,276, filed on Jan. 24, 2012, incorporated herein by reference in its entirety.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates generally to computing devices. More specifically, the present invention relates to hardware acceleration of web applications.

2. Description of the Related Art

A general purpose graphics processing unit (GPU) is a type of processor that has been specifically designed to perform compute intensive and graphics related computations. They can rapidly manipulate and alter memory in such a way so as to accelerate both image and non-image related computations. GPUs are used in embedded systems, mobile phones, personal computers, workstations, and game consoles, among other devices. Modern GPUs are very efficient at manipulating computer graphics and for compute intensive problems, and their highly parallel structure makes them more effective than general-purpose CPUs for algorithms where processing of large blocks of data is done in parallel.

Other high performance processors, such as general purpose multi-core central processing units (CPUs) have also been finding their way into more and more devices. However, the performance and power efficiency of GPUs surpasses general purpose CPUs.

Web applications, such as those commonly run on smart phones and computers operating web browsers, rely on the standard processor on whatever device they are running to execute the processes and computations required by the web applications. As web applications become more and more compute and graphics intensive, consumers are demanding better and better processing times for the applications.

Open Computing Language (OpenCL) is a framework for writing programs that execute across heterogeneous platforms consisting of central processing unit (CPUs), graphics processing unit (GPUs), and other processors and accelerators. Software can then be designed to use OpenCL to facilitate the use of GPUs or multi-core processors to process sections of the software and for parallelization. The problem with this approach, however, is that it is difficult to extend such functionality to a broad scope of web applications. Unlike more traditional software, web applications essentially are two pieces of application software—the application itself, and the web browser that runs the application. While individual web application designers can design their web applications specifically to utilize OpenCL, this utilization would only apply to their own web application, and not to other web applications run by the browser. Requiring individual web application designers, many of whom are smaller companies or even individuals in the smart phone age, to design applications using OpenCL is a significant impediment to its acceptance. Additionally, support for the use of a GPU through a browser, to run a web application helps not only that particular web application, but also other applications running on the computing device, which suddenly will have more processing power available.

As such, what is needed is a solution that allows for a higher level of abstraction on top of parallelization APIs such as OpenCL, that can be utilized by a web browser and apply to any web application that the web browser runs.

SUMMARY

In a first embodiment of the present invention, a method for enabling hardware acceleration of web applications is provided, comprising: parsing a web page using a scripting engine, wherein the web page necessitates running a web application; accessing one or more parallelization Application Program Interfaces (APIs), that distribute tasks of the web application among multiple cores of a multi-core central processing unit (CPU) or graphical processing unit (GPU), wherein the accessing uses a compute context class that, when instantiated, creates a compute context object that acts as a bridge between the scripting engine and the one or more APIs; and creating one or more kernels to operate on the multiple cores.

In a second embodiment of the present invention, a method for enabling hardware acceleration of web applications is provided, comprising: providing a scripting language binding to an open standard for APIs for accelerating web applications by distributing tasks among multiple cores of multi-core CPUs and GPUs; and providing a modified browser containing support for the open standard as well as support for the binding.

In a third embodiment of the present invention, a web browser operable on a computer having access to multiple cores of a multi-core CPU or GPU is provided, the web browser comprising: a user interface front end; a scripting language engine; a scripting language engine binder; a Document Object Model (DOM) interpreter; a parser; a loader; a platform port including a port to an open standard for APIs for accelerating web applications by distributing tasks among multiple cores of multi-core CPUs and GPUs; and a hardware acceleration core configured to access the one or more APIs through the port to the open standard, wherein the accessing uses a compute context class that, when instantiated, creates a compute context object that acts as a bridge between the scripting engine and the one or more APIs; and create one or more kernels to operate on the multiple cores.

In a fourth embodiment of the present invention, an apparatus for enabling hardware acceleration of web applications, comprising: means for providing a scripting language binding to an open standard for parallelization APIs for accelerating web applications by distributing tasks among multiple cores of multi-core CPUs and GPUs; and means for providing a modified browser containing support for the open standard as well as support for the binding.

In a fifth embodiment of the present invention, a program storage device readable by a machine tangibly embodying a program of instructions executable by the machine to perform a method for enabling hardware acceleration of web applications is provided, the method comprising: parsing a web page using a scripting engine, wherein the web page necessitates running a web application; accessing one or more Application Program Interfaces (APIs) that distribute tasks of the web application among multiple cores of a multi-core central processing unit (CPU) or graphical processing unit (GPU), wherein the accessing uses a compute context class that, when instantiated, creates a compute context object that acts as a bridge between the scripting engine and the one or more APIs; and creating one or more kernels to operate on the multiple cores.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a class diagram of hardware acceleration using WebKit in accordance with an embodiment of the present invention.

FIG. 2 is a diagram illustrating the code snippet for initialization in accordance with this embodiment of the present invention.

FIG. 3 is a diagram illustrating the example code related to kernel creation in accordance with this embodiment of the present invention.

FIG. 4 illustrates several examples of this embodiment of the present invention.

FIG. 5 is a diagram illustrating an example of the code for such a binding in accordance with this embodiment of the present invention.

FIG. 6 is a block diagram illustrating browser architecture using a JavaScript or similar application.

FIG. 7 is a block diagram illustrating browser architecture using an application with Web Acceleration, in accordance with an embodiment of the present invention.

FIG. 8 is a flow diagram illustrating a method for enabling hardware acceleration of web applications in accordance with an embodiment of the present invention.

DETAILED DESCRIPTION

Reference will now be made in detail to specific embodiments of the invention including the best modes contemplated by the inventors for carrying out the invention. Examples of these specific embodiments are illustrated in the accompanying drawings. While the invention is described in conjunction with these specific embodiments, it will be understood that it is not intended to limit the invention to the described embodiments. On the contrary, it is intended to cover alternatives, modifications, and equivalents as may be included within the spirit and scope of the invention as defined by the appended claims. In the following description, specific details are set forth in order to provide a thorough understanding of the present invention. The present invention may be practiced without some or all of these specific details. In addition, well known features may not have been described in detail to avoid unnecessarily obscuring the invention.

In accordance with the present invention, the components, process steps, and/or data structures may be implemented using various types of operating systems, programming languages, computing platforms, computer programs, and/or general purpose machines. In addition, those of ordinary skill in the art will recognize that devices of a less general purpose nature, such as hardwired devices, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), or the like, may also be used without departing from the scope and spirit of the inventive concepts disclosed herein. The present invention may also be tangibly embodied as a set of computer instructions stored on a computer readable medium, such as a memory device.

In an embodiment of the present invention, the high-performance computation capabilities of multi-core CPUs and programmable GPUs are made easily accessible to web applications, resulting in significant performance gains. The approach outlined in this document may be used as an open standard that can be implemented by any web browser. It is a cross-platform technology, independent of the operating system and native libraries on the operating device. Exposing multi-core or graphics-core computation to web applications fits well with the strategy of developing web-centric platforms for future mobile devices.

In an embodiment of the present invention, the OpenCL standard is leveraged by using a JavaScript API for interacting between a web application and OpenCL. As such, this embodiment can be thought of as being built “on top of” OpenCL. It should be noted, however, that this is merely one embodiment of the present invention, and other embodiments are contemplated that do not utilize OpenCL, which may utilize other APIs providing access to parallelization and/or hardware acceleration.

In an embodiment of the present invention, a single namespace is utilized, where there is a single JavaScript object used to access hardware acceleration through OpenCL. Error handling for hardware acceleration is performed by calling an error reporting and handling module, and checking for errors received from OpenCL. Direct access is provided to the OpenCL initialization APIs.

Furthermore, blocking for kernel execution commands is deliberately not supported in an embodiment of the present invention, to prevent against the potential of long running kernels resulting in denial of service, by hindering interactivity of JavaScript applications. For example, in contrast to the OpenCL clFinish( ) API, which blocks until all previously queued OpenCL commands in a command queue are issued to the associated device and completed, a clFinish( ) command in accordance with this embodiment of the present invention takes a callback function provided by the user. Additionally, in the interest of security and portability, only kernel executables built from source code are allowed as part of the web pages. Program executables using pre-compiled binary are not permitted.

WebKit is a layout engine designed to allow a web browser/runtime to render web pages and execute web widgets and applications. The WebKit engine includes three main components, WebCore, JavaSCriptCore, and WebKit. WebCore is a layout, rendering, and Document Object Model (DOM) library for HTML and Scalable Vector Graphics (SVG). JavaScriptCore is a JavaScript engine that interprets or Just-in-time (JIT) compiles and executes JavaScript. WebKit wraps WebCore and JavaScriptCore to provide a common application programming interface (API) to browser or application developers. In an embodiment of the present invention, WebKit is utilized as part of the implementation. This document will describe the present invention in terms of WebKit, although one of ordinary skill in the art will recognize that other implementations are possible as well.

WebKit is used as a codebase for the hardware acceleration implementation for web applications. A JavaScript binding is provided for OpenCL to web applications by modifying the internal binding mechanism implemented in WebCore. FIG. 1 is a class diagram of hardware acceleration using WebKit in accordance with an embodiment of the present invention.

The present invention may be known as Web Acceleration, and will be referred to as such throughout this document.

The bridge between JavaScript and OpenCL is the WebCLComputeContext class. A WebCLComputeContext object is associated with the current browsing context, specifically Window object, by being inherited from ActiveDOMObject object. WebCLComputeContext object is a main object in the design and implementation of Web Acceleration, which defines and implements most of the JavaScript APIs which are used by web application developers. Other hardware acceleration objects such as WebCLContext, WebCLDevice, WebCLPlatform, WebCLKernel, WebCLMemObject, WebCLCommandQueue, etc. maintain native OpenCL objects as member variables and are being used as arguments of Hardware Acceleration APIs defined in WebCLComputeContext object.

During initialization, OpenCL APIs are accessed from JavaScript through the WebCLComputeContext class. The compute context for hardware acceleration is inialized by creating a new WebCLComputeContext object. FIG. 2 is a diagram illustrating the code snippet for initialization in accordance with this embodiment of the present invention.

For kernel creation, the source code of the kernel can be described in a C99-like language and the corresponding program is created and built by calling createProgramWithSource( ) and buildProgram( ) respectively. The actual kernel is then created by createKernel( ). FIG. 3 is a diagram illustrating the example code related to kernel creation in accordance with this embodiment of the present invention.

Memory objects can be created from different objects in JavaScript, such as canvas image, JavaScript image, and Typed Arrays. FIG. 4 illustrates several examples of this embodiment of the present invention.

For kernel execution, the hardware acceleration APIs cl.createBuffer( ), cl.enqueueWriteBuffer( ), cl.setKernelArg( ), cl.getKernelWorkGroupInfo( ) and cl.enqueNDRangeKernel( ) APIs provide bindings to the corresponding OpenCL APIs createBuffer( ), enqueueWriteBuffer( ), setKernelArg( ), getKernelWorkGroupInfo( ) and enqueueNDRangeKernel( ), for creating buffer objects, writing the host memory to GPU memory, setting values for kernel parameters, returning work group related information such as size, and initiation of kernel execution, respectively. FIG. 5 is a diagram illustrating an example of the code for such a binding in accordance with this embodiment of the present invention.

For hardware acceleration cleanup, the hardware acceleration APIs cl.releaseMemObject(Input), cl.releaseProgram(program), cl.releaseKernel( ), cl.releaseCommandQueue( ) and cl.releaseContext( ) APIs provide bindings to the OpenCL APIs releaseMemObject( ), releaseProgram( ), releaseKernel( ), releaseCommandQueue( ) and releaseContrext( ) for deleting memory, program, kernel, command queue, and context objects, respectively.

For interoperation with WebGL, the hardware acceleration and WebGL may be used in conjunction, in two configurations, both of which utilize the interoperability provided between OpenCL and OpenGL. These modes are (a) Pre-processing, where hardware acceleration provides inputs to WebGL, and (b) Post-processing, where WebGL provides input to hardware acceleration. In addition, other configurations, or a combination of above may also be possible.

The application creates a hardware acceleration context via the cl.createSharedContext( ) API, which is used to create context for hardware. The application can then create a hardware acceleration memory object (buffer) that is associated with a WebGL buffer via the createFromGLBuffer( ) API. When the hardware acceleration processes the buffer, it is acquired and then released by calling enqueueAcquireGLObjects( ) and enqueueReleaseGLObjects( ), respectively.

FIG. 6 is a block diagram illustrating browser architecture using a JavaScript or similar application. The browser 600 includes a URL bar 602 and a toolbar 604, as well as a webview component 606. The webview component 606 includes a WebkitAPI 608, WebCore support 610, and a WebCore 612. Other components include a JavaScript core 614, backing store 616, and platform port 618. The WebCore 612 includes a DOM interpreter 620, a parser 622, and a loader 624.

JavaScript pages are parsed using the JavaScript core 614. A JavaScript engine in the JavaScript core 614 then performed interpretation, including byte-code generation, machine code generation, JavaScript execution, and garbage collection. The DOM interpreter 620 then parses the web page, creates DOM trees, and loads resources. After this is done, compute image pixels are drawn on the screen using a user interface 626.

FIG. 7 is a block diagram illustrating browser architecture using a Web accelerated application, in accordance with an embodiment of the present invention. In this embodiment, an additional Web AccelerationCore 700 is added to the architecture of FIG. 6 to allow for communication with an OpenCL Framework 702. As such, JavaScript pages for Web Acceleration are parsed by the JavaScript engine 704, and the JavaScript engine also performs interpretation, including byte-code generation, machine code generation, JavaScript execution, and garbage collection. The DOM interpreter 706 then parses the web page, creates DOM trees, and loads resources. The JavaScript binding code then calls the OpenCL port 708 to perform initialization for Web Acceleration, kernel/buffer creation, kernel executions, results read-backs, and release resource operations. The Web Acceleration Core 700 then interfaces with the OpenCL Framework 702 through the OpenCL port 708. The OpenCL Framework 702 can then perform various actions to establish the tasks on different CPU and GPU devices, including the creation and compilation of the kernel for the target device, the creation of data and arguments for kernels and memory objects, and the execution of the kernel and reading back of the results. Kernels can then be executed in the appropriate multi-core CPU or GPUs.

FIG. 8 is a flow diagram illustrating a method for enabling hardware acceleration of web applications in accordance with an embodiment of the present invention. At 800, a web page is parsed using a scripting engine. The web page necessitates running a web application. At 802, one or more APIs that distribute tasks of the web application among multiple cores of a multi-core CPU or GPU are accessed. The accessing involves using a compute context class that, when instantiated, creates a compute context object that acts as a bridge between the scripting engine and the one or more APIs. At 804, one or more kernels are created to operate on the multiple cores. At 806, the kernels are executed using bindings. At 808, clean up is performed using bindings.

It should be noted that to one of ordinary skill in the art, the aforementioned example architectures can be implemented in many ways, such as program instructions for execution by a processor, as software modules, microcode, as computer program product on computer readable media, as logic circuits, as application specific integrated circuits, as firmware, as consumer electronic device, etc. and may utilize wireless devices, wireless transmitters/receivers, and other portions of wireless networks. Furthermore, embodiment of the disclosed method and system for displaying multimedia content on multiple electronic display screens can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment containing both software and hardware elements.

The term “computer readable medium” is used generally to refer to media such as main memory, secondary memory, removable storage, hard disks, flash memory, disk drive memory, CD-ROM and other forms of persistent memory. It should be noted that program storage devices, as may be used to describe storage devices containing executable computer code for operating various methods of the present invention, shall not be construed to cover transitory subject matter, such as carrier waves or signals. Program storage devices and computer readable medium are terms used generally to refer to media such as main memory, secondary memory, removable storage disks, hard disk drives, and other tangible storage devices or components.

Although only a few embodiments of the invention have been described in detail, it should be appreciated that the invention may be implemented in many other forms without departing from the spirit or scope of the invention. Therefore, the present embodiments should be considered illustrative and not restrictive and the invention is not to be limited to the details given herein, but may be modified within the scope and equivalents of the appended claims. 

What is claimed is:
 1. A method for enabling hardware acceleration of a web application, comprising: parsing a web page using a scripting engine, wherein the web page necessitates running the web application; and accessing, through a compute context object, one or more Application Program Interfaces (APIs) that distribute tasks of the web application among multiple cores of a multi-core central processing unit (CPU) or graphical processing unit (GPU) to create one or more kernels to operate on the multiple cores, wherein the compute context object is created in response to instantiating a compute context class, the compute context object acts as a bridge between the scripting engine and the one or more APIs, the compute context object defines one or more hardware acceleration APIs providing one or more bindings to the one or more APIs, the one or more kernels operate on the multiple cores using the one or more bindings, the compute context object further defines one or more additional hardware acceleration APIs providing one or more additional bindings to the one or more APIs, clean up in response to the hardware acceleration of the web application is performed using the one or more additional bindings, the one or more APIs are one or more OpenCL APIs, and the one or more additional hardware acceleration APIs comprise one or more Web Acceleration APIs that are bound to the one or more OpenCL APIs.
 2. The method of claim 1, wherein the scripting engine is a JavaScript engine.
 3. The method of claim 1, wherein the one or more hardware acceleration APIs comprise one or more additional Web Acceleration APIs that are bound to the one or more OpenCL APIs.
 4. A method for enabling hardware acceleration of a web application, comprising: providing one or more scripting language bindings to an open standard for one or more Application Program Interfaces (APIs) for accelerating the web application by distributing tasks of the web application among multiple cores of a multi-core central processing unit (CPU) or graphical processing unit (GPU) to create one or more kernels to operate on the multiple cores; and providing a modified browser containing support for the open standard as well as support for the one or more scripting language bindings; wherein a compute context object is created in response to instantiating a compute context class, the compute context object acts as a bridge between a scripting engine and the one or more APIs, the compute context object defines one or more hardware acceleration APIs providing the one or more scripting language bindings to the one or more APIs, the one or more kernels operate on the multiple cores using the one or more scripting language bindings, the compute context object further defines one or more additional hardware acceleration APIs providing one or more additional scripting language bindings to the one or more APIs, clean up in response to the hardware acceleration of the web application is performed using the one or more additional scripting language bindings, the one or more APIs are one or more OpenCL APIs, and the one or more additional hardware acceleration APIs comprise one or more Web Acceleration APIs that are bound to the one or more OpenCL APIs.
 5. The method of claim 4, wherein the one or more scripting language bindings comprise a JavaScript binding.
 6. The method of claim 4, wherein the open standard is OpenCL.
 7. A web browser stored in a storage memory operable on a computer having access to multiple cores of a multi-core central processing unit (CPU) or graphical processing unit (GPU), the web browser comprising: a user interface front end; a web view module including: a scripting language engine; a Web Core, the Web Core including: one or more scripting language engine binders; a Document Object Model (DOM) interpreter; a parser; a loader; a platform port including a port to an open standard for one or more Application Program Interfaces (APIs) for accelerating a web application by distributing tasks of the web application among the multiple cores; and a Web Acceleration Core configured to: access, through a compute context object, the one or more APIs through the port to the open standard to create one or more kernels to operate on the multiple cores, wherein the compute context object is created in response to instantiating a compute context class, the compute context object acts as a bridge between the scripting language engine and the one or more APIs, the compute context object defines one or more hardware acceleration APIs providing the one or more scripting language engine binders to the one or more APIs, the one or more kernels operate on the multiple cores using the one or more scripting language engine binders, the compute context object further defines one or more additional hardware acceleration APIs providing one or more additional scripting language engine binders to the one or more APIs, clean up in response to hardware acceleration of the web application is performed using the one or more additional scripting language engine binders, the one or more APIs are one or more OpenCL APIs, and the one or more additional hardware acceleration APIs comprise one or more Web Acceleration APIs that are bound to the one or more OpenCL APIs.
 8. The web browser of claim 7, wherein the user interface front end is configured to compute one or more image pixels and draw the one or more image pixels to a screen.
 9. The web browser of claim 7, wherein the scripting language engine is a JavaScript engine.
 10. The web browser of claim 7, wherein the one or more scripting language engine binders comprise a JavaScript engine binder.
 11. The web browser of claim 7, wherein the open standard is OpenCL. 